
use "$input/yu_ash_ready", clear

* use data after 1965
keep if year >= 1965


*******************************
*Table A2
*******************************
eststo clear

** limit to the set of states with random assignment
eststo: reghdfe cites_pos_m_log  polar_start if rule_P & rule_rand_assign==1, absorb(stateyear i.statefe#c.x_year_start x_decade_start) cluster(state year)
outreg2 using "$output/tables/tabA2",excel replace se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Court-year FE, X, Cohort FE, X, StatexStart-year,X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

** alternative weighting such as by size of caseload.
eststo: reghdfe cites_pos_m_log   polar_start if rule_P [aw=numops], absorb(stateyear i.statefe#c.x_year_start x_decade_start) cluster(state year)
outreg2 using "$output/tables/tabA2",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Court-year FE, X, Cohort FE, X, StatexStart-year,X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

**  control for electoral incentives by adding state year times electoral cycle fixed effect.
eststo: reghdfe cites_pos_m_log   polar_start if rule_P, absorb(stateyear i.statefe#c.x_year_start x_decade_start electupP) cluster(state year)
outreg2 using "$output/tables/tabA2",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Court-year FE, X, Cohort FE, X, StatexStart-year,X, Electoral Cycle FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes


**split samples to previous judges and non-judges
eststo: reghdfe cites_pos_m_log   polar_start if rule_P&x_prevjudge, absorb(stateyear) cluster(state year)
outreg2 using "$output/tables/tabA2",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

eststo: reghdfe cites_pos_m_log   polar_start if rule_P&(1-x_prevjudge), absorb(stateyear) cluster(state year)
outreg2 using "$output/tables/tabA2",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes
*******************************
*Table A3
*******************************
insheet using "$input/new_linked_spending.csv", clear

egen z2amount = std (amount)
egen z2polar= std (masspartisandivergence)

eststo clear

eststo: reghdfe z2amount z2polar if elect_type== "General", absorb(year) cluster(year)
outreg2 using "$output/tables/tabA3",excel replace alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Year FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

*******************************
*Table A4
*******************************
use "$input/yu_ash_ready_primaries",clear
* only need one observation per state year
duplicates drop state year, force

gen log_candidates = log(sum_candidates)

eststo clear
eststo: reghdfe log_candidates polar  , cluster(state year) absorb(year)
outreg2 using "$output/tables/tabA4",excel replace se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Year FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

eststo: reghdfe log_candidates  polar  , cluster(state year) absorb(year state)
outreg2 using "$output/tables/tabA4",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Year FE, X, State FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

eststo: reghdfe has_runoff polar   , cluster(state year) absorb(year)
outreg2 using "$output/tables/tabA4",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Year FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes

eststo: reghdfe has_runoff polar   , cluster(state year) absorb(year state)
outreg2 using "$output/tables/tabA4",excel append se alpha(0.01, 0.05, 0.1) symbol(**, *, +) addtext(Year FE, X, State FE, X) addstat(Adjusted R-squared,  e(r2_a)) nocons nor2 nonotes


